package com.kly.sc.api.application.controller.user.request;

import com.fqgj.common.api.ParamsObject;
import com.kly.sc.api.infras.enums.RestCodeEnum;
import com.kly.sc.api.infras.exception.ApplicationException;
import com.kly.user.enums.LikeEnum;
import org.apache.commons.lang3.StringUtils;

import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.util.Objects;

/**
 * 用户喜欢请求类
 * @author linqu
 */
public class DoUserLikeRequest extends ParamsObject {

    /**
     * 用户内码
     */
    @NotEmpty
    private String userCodeFriend;
    /**
     * 用户喜好：1-喜欢 2-不喜欢
     */
    @NotNull
    private Integer likeType;

    /**
     * 1-homepage页面 2-wlm页面
     */
    private String source;

    /**
     * flashchat标记
     */
    private Boolean flashchatFlag;

    public Boolean getFlashchatFlag() {
        return flashchatFlag;
    }

    public void setFlashchatFlag(Boolean flashchatFlag) {
        this.flashchatFlag = flashchatFlag;
    }

    public Integer getLikeType() {
        return likeType;
    }

    public void setLikeType(Integer likeType) {
        this.likeType = likeType;
    }

    public String getUserCodeFriend() {
        return userCodeFriend;
    }

    public void setUserCodeFriend(String userCodeFriend) {
        this.userCodeFriend = userCodeFriend;
    }


    public String getSource() {
        return source;
    }

    public void setSource(String source) {
        this.source = source;
    }

    @Override
    public void validate() {
        if (StringUtils.isBlank(this.userCodeFriend)) {
            throw new ApplicationException(RestCodeEnum.USERID_NOT_EXIST_ERROR);
        }
        if (Objects.isNull(this.likeType)) {
            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR);
        }
        final LikeEnum likeEnum = LikeEnum.fromType(this.likeType);
        if (Objects.isNull(likeEnum)) {
            throw new ApplicationException(RestCodeEnum.SYSTEM_PARAMETER_ERROR);
        }
    }
}
